<template>
  <div class="tab-bar-item" @click="itemclick">
    <div v-if="iactive">
      <slot name="item-log"></slot>
    </div>
    <div v-else>
      <slot name="item-log-active"></slot>
    </div>
    <div :style="activestyle">
      <slot name="item-text"></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: "tabbaritem",
  props: {
    path: String,
    activecolor: {
      type: String,
      default: "red",
    },
  },
  data() {
    return {
     
    };
  },
  computed: {
    iactive() {
      return this.$route.path.indexOf(this.path);
    },
    activestyle() {
      return !this.iactive
        ? {
            color: this.activecolor,
          }
        : {};
    },
  },
  methods: {
    itemclick() {
      //   this.$router.push(this.path);
      this.$router.push(this.path).catch((err) => err);
    },
  },
};
</script>

<style>
/* .active {
  color: #1296db;
} */
.tab-bar-item {
  flex: 1;
  text-align: center;
  height: 49px;
}
.tab-bar-item img {
  width: 24px;
  height: 24px;
  vertical-align: middle;
}
</style>